﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using AMS.DataAccess.Trademark.Interfaces;
using AMS.DataAccess.Trademark.Filters;
using AMS.DataAccess.Trademark.BO;

public partial class Cases_GetCaseIndexDlg : BaseWorkPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DoDataBind();
            AddTestData();
        }
    }

    const int MaxRowCount = 10;
    private void DoDataBind()
    {
        ICaseBasicInfoManager mgr = ManagerFactory.CreateCaseBasicInfoManager();
        CaseInfoFilter filter = new CaseInfoFilter();
        filter.GetCustomerApplicantInfo = true;
        filter.LimitCount = MaxRowCount;
        List<CaseDisplayInfo> caseList = mgr.GetCaseInfoList(CallContext, filter);
        //DataTable dt = new DataTable();
        //dt.Columns.Add("AID", typeof(int));
        //dt.Columns.Add("CaseIndex", typeof(string));
        //dt.Columns.Add("CaseName", typeof(string));
        //for (int i = 0; i < 5; i++)
        //{
        //    dt.Rows.Add(i, "P000" + i.ToString(), "aaaaabbbcc" + i.ToString());
        //}
        //gv.DataSource = dt;
        gv.DataSource = caseList;
        gv.DataBind();
        if (caseList != null && caseList.Count >= MaxRowCount)
        {
            lblMsg.Text = "记录数超过了" + MaxRowCount.ToString() + ", 请缩小查询范围。";
        }
    }

    private void AddTestData()
    {
        List<CaseDisplayInfo> cases = new List<CaseDisplayInfo>();
        CaseDisplayInfo caseInfo = new CaseDisplayInfo();
        caseInfo.AID = 1;
        caseInfo.CaseIndex = "T0001";
        caseInfo.CaseName = "商标案件1";
        caseInfo.CustomerID = 1;
        caseInfo.CustomerName = "北航";
        cases.Add(caseInfo);

        caseInfo = new CaseDisplayInfo();
        caseInfo.AID = 2;
        caseInfo.CaseIndex = "T0002";
        caseInfo.CaseName = "商标案件2";
        caseInfo.CustomerID = 0;
        caseInfo.CustomerName = null;
        cases.Add(caseInfo);

        gv.DataSource = cases;
        gv.DataBind();
    }
}
